{% extends "base.html" %}
{% comment 'header' %}
# This file is part of opentaps Smart Energy Applications Suite (SEAS).

# opentaps Smart Energy Applications Suite (SEAS) is free software:
# you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# opentaps Smart Energy Applications Suite (SEAS) is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public License
# along with opentaps Smart Energy Applications Suite (SEAS).
# If not, see <https://www.gnu.org/licenses/>.
{% endcomment %}

{% load static %}

{% block title %}Model: {{ object.meter.description }} {{ object.model_class }}{% endblock %}

{% block content %}
<div class="container">

  {% include "core/_breadcrumbs.html" %}

  <div class="card mb-3">
    <div class="card-body">
      <h2 class="d-flex">
        Model {{ object.description|default:"" }}
        {% block add_button %}
        <div class="ml-auto text-nowrap">
          <a href="{% url 'core:meter_model_extra_detail' object.meter_id object.id %}" role="button" class="btn btn-primary"><i class="fa fa-cog mr-2"></i> View Details</a>
          <a href="{% url 'core:meter_model_calc_saving' object.meter_id object.id %}" role="button" class="btn btn-primary"><i class="fa fa-dollar-sign mr-2"></i> Calculate Production</a>
          <a href="{% url 'core:meter_model_delete' object.meter_id object.id %}" role="button" class="btn btn-danger"><i class="fa fa-trash mr-2"></i> Delete</a>
        </div>
        {% endblock add_button %}
      </h2>
      {% block inner_content %}
      <p>Model Class <b>{{ object.model_class }}</b>
      Created {{ object.created_datetime }}
      with {% if object.uom %} {{ object.uom.unit }} {% endif %}
      data from {{ object.from_datetime|date:'m/d/Y' }} to {{ object.thru_datetime|date:'m/d/Y' }}.</p>

      {% if object.plot_data %}<img src='data:image/png;base64,{{ object.plot_data }}'/> {% endif %}

      <h4 class="d-flex">
        Meter Production
        <div class="ml-auto text-nowrap">
          <a href="{% url 'core:meter_model_production_delete' object.meter_id object.id %}" role="button" class="btn btn-danger"><i class="fa fa-trash mr-2"></i> Delete Production</a>
        </div>
      </h4>
      {% include "core/_meter_production_chart.html" with meter_id=object.meter_id model_id=object.id no_title=True frequency=object.frequency %}

      <h4 class="d-flex mt-4">
        Meter Financial Value
      </h4>
      {% include "core/_meter_financial_value_table.html" with meter_id=object.meter_id model_id=object.id model=object no_title=True frequency=object.frequency %}

      {% endblock inner_content %}
    </div>
  </div>

</div>
{% endblock content %}
